package Q409

/**
 * 最长回文串
 * @author 23737
 * @date 2022.5.10
 */
fun main(args : Array<String>){
    var s = "abccccdd"
    println(Solution().longestPalindrome(s))
}

class Solution {
    fun longestPalindrome(s: String): Int {
        var arr : IntArray = IntArray(128)
        for(i in s.toCharArray()){
            arr[i.toInt()]++
        }
        var count  = 0
        for(i in arr){
            count += i%2
        }
        if (count == 0) {
            return s.length
        }else{
            return s.length - count + 1
        }
    }
}